package vn.edu.saigontech.ncms.web.offering;

import vn.edu.saigontech.ncms.model.info.OfferingMember;
import vn.edu.saigontech.ncms.service.OfferingMemberService;
import vn.edu.saigontech.ncms.util.Checker;
import vn.edu.saigontech.ncms.web.AbstractValidator;

@SuppressWarnings("serial")
public class ValidateClassSituationAction extends AbstractValidator {
	private Long memberId;
	private String date;
	private String situation;
	
	@Override
	public String check() {
		OfferingMember member = OfferingMemberService.INSTANCE.findById(this.memberId);
		if(Checker.isNull(member)) {
			this.sendKeyError("validator.required", "student");
		}
		
		if (Checker.isEmpty(this.date)) {
			this.sendKeyError("validator.required", "date");
		}
		if (!Checker.isDate(this.date, this.i18n("format.date"))) {
			this.sendKeyError("validator.mask", "date", "format.date");
		}
		if(Checker.isEmpty(situation)) {
			this.sendKeyError("validator.required", "situation");
		}
		return this.toSuccess();
	}

	public Long getMemberId() {
		return memberId;
	}

	public void setMemberId(Long memberId) {
		this.memberId = memberId;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getSituation() {
		return situation;
	}

	public void setSituation(String situation) {
		this.situation = situation;
	}
}
